<?php
require_once("database.php");

function quizzes_POST()
{
	$db = getDBConnection();
	
	$time = time();
	$mysqldate = date( 'Y-m-d H:i:s', $time );
	
	$sql = "INSERT INTO quiz (create_date) VALUES('".$mysqldate."')";
	$result = mysqli_query($db, $sql);
	
	$id = mysqli_insert_id($db);
	$arr = array("id" => $id);
	
	return $arr;
}

function quizzes_DELETE($id)
{
	$db = getDBConnection();
	
	$sql = "DELETE FROM answer WHERE id = '".$id."'";
	mysqli_query($db, $sql);
	
	$sql = "UPDATE question SET opened = '0' WHERE quiz_id = '".$id."' AND qid != '1'";
	mysqli_query($db, $sql);
	
	$sql = "UPDATE question SET opened = '1' WHERE quiz_id = '".$id."' AND qid = '1'";
	mysqli_query($db, $sql);	
}

?>